#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
void setZeroes(int** matrix, int matrixSize, int* matrixColSize)
{
    int m = matrixSize;
    int n = matrixColSize[0];
    int judge = 1;
    for (int i = 0; i < n; i++)
    {
        if (matrix[0][i] == 0)
            judge = 0;
    }
    for (int i = 1; i < m; i++)
    {
        if (matrix[i][0] == 0)
            matrix[0][0] = 0;
    }
    for (int i = 1; i < m; i++)
    {
        for (int j = 1; j < n; j++)
        {
            if (matrix[i][j] == 0)
            {
                matrix[i][0] = 0;
                matrix[0][j] = 0;
            }
        }
    }
    for (int i = 1; i < m; i++)
    {
        if (matrix[i][0] == 0)
        {
            for (int j = 1; j < n; j++)
            {
                matrix[i][j] = 0;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (matrix[0][i] == 0)
        {
            for (int j = 1; j < m; j++)
            {
                matrix[j][i] = 0;
            }
        }
    }
    if (judge == 0)
    {
        for (int i = 0; i < n; i++)
        {
            matrix[0][i] = 0;
        }
    }
}

int main()
{
    int** matrix = (int**)malloc(sizeof(int*) * 3);
    assert(matrix);
    for (int i = 0; i < 3; i++)
    {
        matrix[i] = (int*)malloc(sizeof(int) * 4);
    }
    matrix[0][0] = 0;
    matrix[0][1] = 1;
    matrix[0][2] = 2;
    matrix[0][3] = 0;
    matrix[1][0] = 3;
    matrix[1][1] = 4;
    matrix[1][2] = 5;
    matrix[1][3] = 2;
    matrix[2][0] = 1;
    matrix[2][1] = 3;
    matrix[2][2] = 1;
    matrix[2][3] = 5;
    int* matrixColSize = (int*)malloc(sizeof(int)*3);
    matrixColSize[0] = 4;
    matrixColSize[1] = 4;
    matrixColSize[2] = 4;
    int matrixSize = 3;
    setZeroes(matrix, matrixSize, matrixColSize);
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            printf("%d ", matrix[i][j]);
        }
        printf("\n");
    }
    return 0;
}